home *** CD-ROM | disk | FTP | other *** search
/ Aminet 4 / Aminet 4 - November 1994.iso / aminet / dev / gcc / libnix.lha / gnu / lib / libnix / sources.lha / nix / stdlib / calloc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-01  |  354 b   |  18 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. void *calloc(unsigned long nmemb,unsigned long size)
  5. {
  6.   unsigned long l;
  7.   unsigned long *a;
  8.   void *b;
  9.   l=(nmemb*size+(sizeof(unsigned long)-1))&~(sizeof(unsigned long)-1);
  10.   a=(unsigned long *)(b=malloc(l));
  11.   if(b==NULL)
  12.     return NULL;
  13.   do
  14.     *a++=0;
  15.   while((l-=sizeof(unsigned long))!=0);
  16.   return b;
  17. }
  18.